package com.boc.langxiang.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * CreateTime: 2016-07-06下午4:30
 * Author: wjkjinke00@126.com
 * Description:
 */
public class TimeUtil {
    private TimeUtil() {
    }

    public static final String TYPE_Y_M_D = "yyyy-MM-dd";
    public static final String TYPE_Y_M_D_2 = "yyyy/MM/dd";
    public static final String TYPE_Y_M_D_H_M_S = "yyyy-MM-dd HH:mm:ss";

    public static boolean isSameDay(long time1, long time2) {
        String format1 = formatTime(time1, TYPE_Y_M_D);
        String format2 = formatTime(time2, TYPE_Y_M_D);
        return format1.equals(format2);
    }

    public static String formatTime(long time, String type) {
        SimpleDateFormat formater = new SimpleDateFormat(type);
        Date date = new Date(time * 1000);
        String format = formater.format(date);
        return format;
    }
}
